/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lib;

import java.util.logging.Level;
import java.util.logging.Logger;
import sun.audio.*;    //import the sun.audio package
import java.io.*;

/**
 *
 * @author Wolf
 */
public class AudioLib {

    InputStream in;
    AudioStream as;

    public AudioLib() {
        try {
            //** add this into your application code as appropriate
            // Open an input stream  to the audio file.
            in = new FileInputStream("./audio/Up.wav");
            // Create an AudioStream object from the input stream.
            as = new AudioStream(in);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

// Use the static class member "player" from class AudioPlayer to play
// clip.
        AudioPlayer.player.start(as);
    }

    public void read(String file) {
        try {
            // Similarly, to stop the audio.
            AudioPlayer.player.stop(as);
            //** add this into your application code as appropriate
            // Open an input stream  to the audio file.
            in = new FileInputStream(file);
            // Create an AudioStream object from the input stream.
            as = new AudioStream(in);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

// Use the static class member "player" from class AudioPlayer to play
// clip.
        AudioPlayer.player.start(as);
    }
}
